<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of cek_login
 *
 * @author Shirley
 */
    session_start();
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    if ($username && $password)
    {
        include("connect.php");

        $query = mysql_query("select * from user where username = '$username' and password = '$password'");
        $jmlbaris = mysql_num_rows($query);
        if($jmlbaris != 0)
        {
            while($row = mysql_fetch_assoc($query))
            {
                $dbusername = $row['username'];
                $dbpassword = $row['password'];
            }

            if($username==$dbusername && $password==$dbpassword)
            {
                $_SESSION['username'] = $username;
                //echo"berhasil lhooo";
                include("file.php");
            }
            else
            {

            }
        }
        else
        {
            echo("User tidak terdaftar atau password yang dimasukkan tidak sesuai");
            include("index.php");
            //index.php;
        }
    }
    else
    {
        echo "masukkan username dan password";
        include "index.php";
    }

?>
